package com.flutter.flutter_plugin_params

import android.util.Log
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

class MethodChannelDemo(messenger: BinaryMessenger) : MethodChannel.MethodCallHandler {
    val TAG = "MethodChannelDemo"
    private var channel: MethodChannel = MethodChannel(messenger, "flutter_plugin_params")

    init {
        channel.setMethodCallHandler(this)
    }

    override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
        if (call.method == "sendData") {
            Log.d(TAG, "onMethodCall: ${call.method}")
            var name = call.argument("name") as String?
            var age = call.argument("age") as Int?
            var map = mapOf("name" to "hello,$name", "age" to "$age")
            result.success(map)
        }
    }

}